/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __DEVFS_H__
#define __DEVFS_H__

/* includes (standard library, system) ---------------------------------------*/
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
/* includes (local) ----------------------------------------------------------*/
#include "vfs.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* defines -------------------------------------------------------------------*/
/* typedefs ------------------------------------------------------------------*/

struct devfs_ops {
    int (*open)(uintptr_t);
    int (*close)(uintptr_t);
    int (*read)(uintptr_t, char *, size_t);
    int (*write)(uintptr_t, const char *, size_t);
    int (*lseek)(uintptr_t, int, int);
    int (*ioctl)(uintptr_t, int, va_list);
    int (*sync)(uintptr_t);
    int (*stat)(uintptr_t, struct stat *);
    size_t (*size)(uintptr_t);
};

/* macro ---------------------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* externs -------------------------------------------------------------------*/

extern int devfs_add_file(const char *, const struct devfs_ops *, uintptr_t);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __DEVFS_H__ */
